import request from "@/utils/request";

/**
 * 整改分类tree
 */
export const rectificationTypeTree = (afterSalesType, isShow = "") => {
  return request({
    url: `/crm/reform/type/node/listTree?afterSalesType=${afterSalesType}&isShow=${isShow}`,
    method: "get"
  });
};
//整改增减项原因分类树
export const serviceReasonTypeTree = afterSalesType => {
  return request({
    url: `/crm/serviceReason/node/listTree?afterSalesType=${afterSalesType}`,
    method: "get"
  });
};
//整改增减项模板
export const templateType = packageType => {
  return request({
    url: `/crm/reform/template/list?packageType=${packageType}`,
    method: "get"
  });
};

/**
 * 整改管理分页查询
 * @param { RectificationPageParams } data
 * @returns { RectificationPageData }
 */
export const rectificationManagerList = data => {
  return request({
    url: "/crm/reform/management/page",
    method: "post",
    data
  });
};

/**
 * 批量核实
 * @param { array } data
 **/
export const rectificationBatchVerify = data => {
  return request({
    url: "/crm/reform/management/assignBlame/batchConfirm",
    method: "put",
    data
  });
};

/**
 * 条件导出
 * @param { RectificationPageParams } params
 */
export const rectificationExport = data => {
  return request({
    url: "/crm/reform/management/excel/export",
    method: "post",
    responseType: "blob",
    data
  });
};

/**
 * 查询判责信息
 * @param { string } reformId
 * @returns { RectificationJudgeParamsItem[] }
 */
export const rectificationJudgeInfo = reformId => {
  return request({
    url: `/crm/reform/management/assignBlame/detail/${reformId}`,
    method: "get"
  });
};

/**
 * 判责
 * @param { string } reformId
 * @param { RectificationJudgeParamsItem[] } data
 */
export const rectificationJudge = (reformId, data) => {
  return request({
    url: `/crm/reform/management/assignBlame/save/${reformId}`,
    method: "post",
    data
  });
};

/**
 * 判责责任人
 */
export const getRectificationResponsi = value => {
  return request({
    url: `/finance/partner/getPerson/${value}`
  });
};

/**
 * 查询售后原因列表
 */
export const listTemplate = params => {
  return request({
    url: "/crm/serviceReason/node/listTree",
    method: "get",
    params
  });
};
/**
 * 作废整改
 */
export const reformDelete = reformId => {
  return request({
    url: `/crm/reform/${reformId}/cancel`,
    method: "put"
  });
};
/**
 * 获取状态数量
 */
export const stateCount = data => {
  return request({
    url: "/crm/reform/management/getStateCount",
    method: "post",
    data
  });
};
/**
 * 开始任务
 */
export const startTask = params => {
  return request({
    url: "/crm/reform/management/startTask",
    method: "get",
    params
  });
};
/**
 * 撤销审批
 */
export const deleteTask = reformId => {
  return request({
    url: `/crm/reform/${reformId}/cancel-proc-instance`,
    method: "delete"
  });
};
/**
 * 查询状态为待发起客户确认/客户拒绝得所有客户信息
 */
export const queryAllCustomers = () => {
  return request({
    url: "/crm/reform/queryAllCustomers",
    method: "post",
    data: {}
  });
};
/**
 * 发起批量客户确认批量
 */
export const sendCustomerConfirmBatch = data => {
  return request({
    url: "/crm/reform/sendCustomerConfirmBatch",
    method: "post",
    data
  });
};
/**
 * 发起单个客户确认批量
 */
export const sendCustomerConfirmSingle = reformId => {
  return request({
    url: `/crm/reform/sendCustomerConfirmSingle/${reformId}`,
    method: "get"
  });
};
/**
 * 撤销发起客户确认
 */
export const revokeCustomer = msgId => {
  return request({
    url: `/crm/reform/revokeCustomerConfirmSingle/${msgId}`,
    method: "get"
  });
};
/**
 * 客户名称模糊查询
 */
export const getCustomerByName = params => {
  return request({
    url: "/crm/info/getCustomerByName",
    method: "get",
    params
  });
};
/**
 * 根据单据id查询 partnerId 用来付款
 */
export const getSlipDetail = slipId => {
  return request({
    url: `/crm/reform/getSlipDetail/${slipId}`,
    method: "get"
  });
};
/**
 * 根据客户id查询客户待付款的财务单据
 */
export const paymentOrder = data => {
  return request({
    url: "/crm/reform/paymentOrder",
    method: "post",
    data
  });
};
// 收款账户
export const getMyAccountList = data => {
  return request({
    url: "/finance/account/page",
    method: "post",
    data
  });
};
/**
 * 获取预收款可使用的单据
 */
export const available = partnerId => {
  return request({
    url: `/finance/receipt/getNotUseReceipt/${partnerId}`
  });
};
// 付款
export const payment = data => {
  return request({
    url: "/crm/reform/payment",
    method: "post",
    data
  });
};